/**
 * 
 */
package pt.mleiria.cryptographic.utils;

import java.util.Map;
import java.util.TreeMap;

/**
 * @author NB13712
 *
 */
public class Utils {
	
	public static Map<Character, Integer> letterFrequency(String cipherText){
		final Map<Character, Integer> freqAnalyzer = new TreeMap<Character, Integer>();
		final char[] cipher = cipherText.toLowerCase().toCharArray();
		for(final char c : cipher){
			if(freqAnalyzer.containsKey(c)){
				freqAnalyzer.put(c, freqAnalyzer.get(c) +1);
			}else{
				freqAnalyzer.put(c, 1);
			}
		}
		return freqAnalyzer;
	}
	
	/**
	 * Ordenado do maior para o menos
	 * @return
	 */
	public static char[] ukAlphabetFrequency(){
		return new char[]{'e','t','a','o','i','n','s','h','r','d','l','c','u','m','w','f','g','y','p','b','v','k','j','x','q','z'};
	}

}
